/* Kanvas Paint and Drawing Tool.
 * Copyright (C) 2011 Darryl Wallace
 * wallacdj@gmail.com / darryl@wallynet.ca
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*!
  @file BrushTool.h
  @author Darryl Wallace
  @date 2011
  @brief This file defines the interface to the brush tool.
  */

#ifndef BRUSHTOOL_H
#define BRUSHTOOL_H

#include <QtCore>
#include <QtGui>
#include "ITool.h"

class LayerItem;

class BrushTool : public ITool
{
    Q_OBJECT
public:
    Q_INVOKABLE BrushTool();

    ~BrushTool();

    ToolType toolType() const {return Drawing;}
    void setLayerItem(LayerItem *);
    void setPrimaryColor(const QColor &p);
    void setSecondaryColor(const QColor &s);
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0);
    void paintOnImage(QPainter *painter);
    void handleMousePressEvent(const QGraphicsSceneMouseEvent *e);
    void handleMouseMoveEvent(const QGraphicsSceneMouseEvent *e);
    void handleMouseReleaseEvent(const QGraphicsSceneMouseEvent *e);
    QRectF boundingRect() const {return _boundingRect;}
    QList<QWidget *> toolbarWidgets() const {return _widgets;}
    QString toolName() const {return "Paintbrush";}
    QIcon toolIcon() const;
    const QPen & pen() const {return _p;}
    void setPen(const QPen &pen);

    UpdateMode updateMode() const {return BoundingRect;}    // only update the bounding rect for the BrushTool

private:
    LayerItem *_parent;

    QColor _primary;
    QColor _secondary;

    QPen _p;
    QBrush _b;

    QPointF _initial;
    QPointF _current;
    QPointF _last;
    QRectF _boundingRect;
    QList<QWidget *> _widgets;

    QPainterPath _path;



};

#endif // BRUSHTOOL_H
